package com.shoulder.log.event;

import com.shoulder.log.Log;
import com.shoulder.log.printer.LogPrinter;
import lombok.Data;
import org.springframework.context.ApplicationListener;

@Data
public class LogEventListener implements ApplicationListener<LogEvent> {
    private LogPrinter logPrinter;

    public LogEventListener(LogPrinter logPrinter) {
        this.logPrinter = logPrinter;
    }

    @Override
    public void onApplicationEvent(LogEvent logEvent) {
        Log source = (Log) logEvent.getSource();
        logPrinter.print(source);
    }
}